#! /usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright: (c) 2007 by Jarek Zgoda, <jzgoda@o2.pl>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Steet, Fifth Floor, Boston, MA  02111-1307, USA.

"""The simplest possible client. And yes, this is a joke."""

__revision__ = '$Id$'

import sys

import lastfmsvc

USAGE = """
Usage: exclient.py <username> <password> <operation>
where
  <username> is your Last.FM username
  <password> is your Last.FM password
  <operation> is either "add" or "remove".
"""

ADDED = """
"We Who Are Not as Others" by Sepultura has just been added to your loved
tracks radio. Open your Last.FM Dashboard page and see for yourself. ;)
Don't panic, you can remove it running this script with "remove"
instead of "add" the last argument.
"""

REMOVED = """
"We Who Are Not as Others" by Sepultura has just been removed from your loved
tracks radio. Open your Last.FM Dashboard page and see for yourself. ;)
Don't panic, you can add it back running this script with "add"
instead of "remove" the last argument.
"""

OOPS = """
Expected operation argument is either "add" or "remove" (without quotation
marks).
"""

if __name__ == '__main__':
    if len(sys.argv) < 4:
        print USAGE
        sys.exit(0)
    username, password, operation = sys.argv[1:4]
    artist = u'Sepultura'
    track = u'We Who Are Not as Others'
    svc = lastfmsvc.LastFMService(username.decode('utf-8'),
        password.decode('utf-8'))
    if operation == 'add':
        svc.love(artist, track)
        print ADDED
    elif operation == 'remove':
        svc.remove_from_loved(artist, track)
        print REMOVED
    else:
        print OOPS
